﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using GA.Server.ApiInfo;

namespace GA.Server.Api
{
    [Serializable]
    public class ApiInfoZoneList : SignedApiCall
    {
        public IEnumerable<ApiZone> Zones { get; private set; }

        public ApiInfoZoneList()
        {
        }

        public ApiInfoZoneList(int clientId, string authorizationText, string sessionId)
            : base(clientId, authorizationText, sessionId)
        {
        }

        public void LoadApi()
        {
            LoadSignedApiCall(null);

            XmlNodeList zoneNodes = XmlDocument.GetElementsByTagName("a:stats_hexZones_browseResult");
            List<ApiZone> zones = new List<ApiZone>();
            foreach (XmlNode zoneNode in zoneNodes)
            {
                zones.Add(new ApiZone(zoneNode.CreateNavigator().ReadSubtree()));
            }
            Zones = zones;
        }

        protected override string ApiCallName
        {
            get { return "ZoneList"; }
        }
    }
}
